using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using FikriKibar.Entities.Concrete;

namespace FikriKibar.DataAccess.Mapping
{
    public class KeywordLanguageLineMapping : EntityTypeConfiguration<KeywordLanguageLine>
    {
        public KeywordLanguageLineMapping()
            : this("dbo")
        {
        }
 
        public KeywordLanguageLineMapping(string schema)
        {
            ToTable(schema + ".KeywordLanguageLine");
            HasKey(x => x.Id);

            Property(x => x.Id).HasColumnName("Id").IsRequired().HasColumnType("int").HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            Property(x => x.KeywordId).HasColumnName("KeywordId").IsRequired().HasColumnType("int");
            Property(x => x.LanguageId).HasColumnName("LanguageId").IsRequired().HasColumnType("int");
            Property(x => x.KeywordName).HasColumnName("KeywordName").IsRequired().HasColumnType("nvarchar").HasMaxLength(400);
            Property(x => x.KeywordDescription).HasColumnName("KeywordDescription").IsOptional().HasColumnType("nvarchar").HasMaxLength(500);
            Property(x => x.CreateDate).HasColumnName("CreateDate").IsRequired().HasColumnType("datetime");
            Property(x => x.CreatedBy).HasColumnName("CreatedBy").IsRequired().HasColumnType("int");
            Property(x => x.UpdateDate).HasColumnName("UpdateDate").IsRequired().HasColumnType("datetime");
            Property(x => x.UpdatedBy).HasColumnName("UpdatedBy").IsRequired().HasColumnType("int");
            Property(x => x.DisplayOrder).HasColumnName("DisplayOrder").IsRequired().HasColumnType("int");
            Property(x => x.IsApproved).HasColumnName("IsApproved").IsRequired().HasColumnType("bit");

            HasRequired(a => a.Language).WithMany(b => b.KeywordLanguageLines).HasForeignKey(c => c.LanguageId);
            HasRequired(a => a.Keyword).WithMany(b => b.KeywordLanguageLines).HasForeignKey(c => c.KeywordId);
            HasRequired(a => a.User_CreatedBy).WithMany(b => b.KeywordLanguageLines_CreatedBy).HasForeignKey(c => c.CreatedBy);
            HasRequired(a => a.User_UpdatedBy).WithMany(b => b.KeywordLanguageLines_UpdatedBy).HasForeignKey(c => c.UpdatedBy);
        }
    }

}
